package com.sq.partner.manager.service;

import java.sql.Connection;
import java.sql.Statement;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sq.partner.manager.dao.BaseDao;
import com.sq.partner.manager.dao.CommonDao;
import com.sq.partner.manager.mybatis.model.GatewayTrans;
import com.sq.partner.manager.util.SqlUtil;
@Service
public class TestService {
	@Resource
	private CommonDao commonDao;
	public void addTrans(GatewayTrans trans) throws Exception{
		commonDao.add("insertGatewayTrans",trans);
	}
	
	public GatewayTrans queryTrans(Integer id) throws Exception{
		return (GatewayTrans)commonDao.query("queryGatewayTransById",id);
	}
	
	public GatewayTrans queryPage(Integer id) throws Exception{
		return null;
	}
	
	public List queryTransByMap(Map m) throws Exception{
		return commonDao.queryList("queryGatewayTransByMap",m);
	}
	
	
	//update all的处理
	public void updateTransNotNull(GatewayTrans trans) throws Exception{
		commonDao.update("updateGatewayTransNotNull",trans);
	}
	
	public void updateTrans(GatewayTrans trans) throws Exception{
		commonDao.update("updateGatewayTrans",trans);
	}
	
	public void delTrans(GatewayTrans trans) throws Exception{
		commonDao.delete("delGatewayTrans",trans);
	}
	
	 public void batchInsert(final String statementName, final List list) throws Exception{
		 commonDao.batchInsert(statementName, list);
	 }
	 
	public void delTrans(int  id) throws Exception{
		commonDao.delete("delGatewayTransById",id);
	}
	
	public void deluser(int  id) throws Exception{
		String sql = "delete from t_gateway_channel_user where user_name = '11'";
		Connection conn = null;
		Statement stmt = null;
		try{
			conn = commonDao.getConnection();
			System.out.println(conn.hashCode());
			stmt = conn.createStatement();
			stmt.execute(sql);
		}finally{
			SqlUtil.close(stmt);
			SqlUtil.close(conn);
		}
		
		//basedao.delete("delGatewayTransById",id);
	}
}
